#include "Player.h"
#include "Util.h"
#include "Wheel.h"
#include "NxActor.h"
using namespace Ogre;
using namespace OIS;

Player::Player()
{
	
}

void Player::setTarget(Wheel* target)
{
	mTarget=target;
}

void Player::update(float k)
{
	if (isKeyDown(KC_UP))    mTarget->mActor->addLocalTorque(NxVec3(0,15,0), NX_FORCE);
	if (isKeyDown(KC_DOWN))  mTarget->mActor->addLocalTorque(NxVec3(0,-15,0)/*,NxVec3(0,-0.4,0)*/, NX_FORCE);
	//if (isKeyDown(KC_UP)&&isKeyDown(KC_SPACE))    mTarget->mActor->addLocalTorque(NxVec3(0,20000,0), NX_FORCE);
	//if (isKeyDown(KC_DOWN))  mTarget->mActor->addLocalTorque(NxVec3(0,-100,0)/*,NxVec3(0,-0.4,0)*/, NX_FORCE);
	if (isKeyDown(KC_LEFT))  mTarget->mActor->addLocalForce(NxVec3(0,200,0), NX_FORCE);	
	//if (isKeyDown(KC_LEFT))	 mTarget->mActor->addTorque(NxVec3(0,-5,0));
	if (isKeyDown(KC_RIGHT)) mTarget->mActor->addLocalForce(NxVec3(0,-200,0), NX_FORCE);
	//if (isKeyDown(KC_RIGHT)) mTarget->mActor->addTorque(NxVec3(0,5,0));


	if (isKeyDown(KC_A))	 mTarget->mActor->addLocalTorque(NxVec3(0,0,30), NX_FORCE);
	if (isKeyDown(KC_F10))   mTarget->mActor->setGlobalPosition(NxVec3(1,1,7));
	if (isKeyDown(KC_F10))   mTarget->mActor->setLinearVelocity(NxVec3(0,0,0));
	if (isKeyDown(KC_F10))	 mTarget->mActor->setCMassGlobalOrientation(NxMat33(NxVec3(0,1,0),NxVec3(0,0,1),NxVec3(1,0,0)));
	if (isKeyDown(KC_F11))   mTarget->mActor->setLinearVelocity(NxVec3(0,0,0));
	if (isKeyDown(KC_F11))	 mTarget->mActor->setCMassGlobalOrientation(NxMat33(NxVec3(0,1,0),NxVec3(0,0,1),NxVec3(1,0,0)));

	if (isKeyDown(KC_F12))	 mTarget->mActor->setAngularMomentum(NxVec3(0,0,0));
	if (isKeyDown(KC_F12))	 mTarget->mActor->setAngularVelocity(NxVec3(0,0,0));
	// mTarget->mActor->    //>setAngularMomentum(NxVec3(0,0,0));
	//if (!(isKeyDown(KC_RIGHT))) mTarget->mActor->setAngularVelocity(NxVec3(0,0,1));
	//mTarget->mActor->r


}
